package com.gitee.wsl.io.dataproxy

import com.gitee.wsl.ext.list.fill

open class ListProxy<T>(val list: MutableList<T>) : DataProxy<T> {

    override fun iterator() = list.iterator()

    override val size: Int get() = list.size

    override fun get(index: Int): T = list[index]

    override fun set(index: Int, value: T) {
        list[index] = value
    }

    override fun fill(value: T, fromIndex: Int, toIndex: Int) {
        list.fill(value, fromIndex, toIndex)
    }

    override fun values(): List<T> = list
}

//fun<T> MutableList<T>.asProxy() = ListProxy(this)

fun<T> List<T>.asProxy() = ListProxy(this.toMutableList())

